<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>componentReceiveProps</title>
	<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://market-cowen.top/static/17.0.1/react.development.js"></script>
	<script src="https://market-cowen.top/static/17.0.1/react-dom.development.js"></script>
	<script src="https://market-cowen.top/static/17.0.1/babel.min.js"></script>
</head>
<body>
	<div class="container">
		<div id="app"></div>
	</div>
</body>
</html>
<script type="text/babel">
	class App extends React.Component{
		state={num:0}
		static getDerivedStateFromProps(props,state){
			console.log(props)
			console.log(`getDerivedStateFromProps`)
			return {num:100}
		}
		incrementEvent=()=>{
			this.setState(state=>({num:state.num+1}))
		}
		componentDidMount(){
			console.log('componentDidMount')
		}
		componentDidUpdate(){
			console.log('componentDidUpdate')
		}
		render(){
			console.log('render')
			return (
				<div className="rows" style={{padding:'40px'}}>
					<h4>当前数值<strong className="ml-2 text-danger">{this.state.num}</strong></h4>
					<button className='btn btn-primary' onClick={this.incrementEvent}>点击加1</button>	
				</div>
			)
		}
	}
	ReactDOM.render(<App title="APP" />,document.getElementById("app"))
</script>